package com.admin.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**   
 * @Title: CUDUrl.java
 * @Package com.admin.util
 * @Description: 
 * @author Jason
 * @date 2010-12-16 下午01:51:23    
 * @version    
 */
public class CUDUrl {

	private static List<String> urlList = null;
	private static final String BASEURI = "/billing/admin";
	
	static{
		urlList = new ArrayList<String>();
		
		urlList.add("/adminUser/reg");
		urlList.add("/adminUser/updatePwd");
		urlList.add("/adminUser/updateStatus");
		
		urlList.add("/billing/add");
		urlList.add("/billing/del");
		urlList.add("/billing/update");
		
		urlList.add("/billingSp/join");
		urlList.add("/billingSp/del");
		
		urlList.add("/company/add");
		urlList.add("/company/modify");
		urlList.add("/company/del");
		
		urlList.add("/user/update");
		urlList.add("/user/del");
		
		urlList.add("/mobile/add");
		urlList.add("/mobile/update");
		urlList.add("/mobile/del");
		urlList.add("/mobile/addbatch");
		urlList.add("/mobile/delbatch");
		
		urlList.add("/product/add");
		urlList.add("/product/update");
		urlList.add("/product/del");
		
		urlList.add("/sp/add");
		urlList.add("/sp/del");
		urlList.add("/sp/update");
		
		urlList.add("/temp/del");
	}
	
	/**
	  * @Title: checkLogUrl
	  * @Description: 检测访问的URI是否需要记录Log
	  * @param uri
	  * @return
	  * @throws
	 */
	public static boolean checkLogUrl(String uri){
		boolean flag = false;
		Pattern p = null;
		for (String url : urlList) {
			String reg = BASEURI+url+"(/\\w+?)*$";
			p = Pattern.compile(reg);
			Matcher m  =  p.matcher(uri);
			if(m.matches()){
				flag = true;
				break;
			}
		}
		return flag;
	}
}
